﻿using System;
using System.Collections.Generic;
using System.Linq;
using Helpers;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.CharacterDevelopment;
using TaleWorlds.CampaignSystem.Conversation;
using TaleWorlds.CampaignSystem.Conversation.Persuasion;
using TaleWorlds.CampaignSystem.Encounters;
using TaleWorlds.CampaignSystem.Extensions;
using TaleWorlds.CampaignSystem.MapEvents;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Party.PartyComponents;
using TaleWorlds.CampaignSystem.Roster;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.LinQuick;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.Issues
{
	// Token: 0x0200031C RID: 796
	public class SmugglersIssueBehavior : CampaignBehaviorBase
	{
		// Token: 0x06002DE0 RID: 11744 RVA: 0x000C09B8 File Offset: 0x000BEBB8
		public override void RegisterEvents()
		{
			CampaignEvents.OnCheckForIssueEvent.AddNonSerializedListener(this, new Action<Hero>(this.OnCheckForIssue));
		}

		// Token: 0x06002DE1 RID: 11745 RVA: 0x000C09D4 File Offset: 0x000BEBD4
		private void OnCheckForIssue(Hero hero)
		{
			Campaign.Current.IssueManager.AddPotentialIssueData(hero, this.ConditionsHold(hero) ? new PotentialIssueData(new PotentialIssueData.StartIssueDelegate(this.OnStartIssue), typeof(SmugglersIssueBehavior.SmugglersIssue), IssueBase.IssueFrequency.Rare, null) : new PotentialIssueData(typeof(SmugglersIssueBehavior.SmugglersIssue), IssueBase.IssueFrequency.Rare));
		}

		// Token: 0x06002DE2 RID: 11746 RVA: 0x000C0A2C File Offset: 0x000BEC2C
		private bool ConditionsHold(Hero issueGiver)
		{
			return issueGiver.IsLord && issueGiver.Clan != Clan.PlayerClan && issueGiver.GetRelationWithPlayer() >= -10f && issueGiver.Clan.Settlements.AnyQ((Settlement settlement) => settlement.Owner == issueGiver && settlement.IsTown);
		}

		// Token: 0x06002DE3 RID: 11747 RVA: 0x000C0A9A File Offset: 0x000BEC9A
		private IssueBase OnStartIssue(in PotentialIssueData pid, Hero issueOwner)
		{
			return new SmugglersIssueBehavior.SmugglersIssue(issueOwner);
		}

		// Token: 0x06002DE4 RID: 11748 RVA: 0x000C0AA2 File Offset: 0x000BECA2
		public override void SyncData(IDataStore dataStore)
		{
		}

		// Token: 0x04000DB2 RID: 3506
		private const IssueBase.IssueFrequency SmugglersIssueFrequency = IssueBase.IssueFrequency.Rare;

		// Token: 0x02000673 RID: 1651
		public class SmugglersIssue : IssueBase
		{
			// Token: 0x0600535D RID: 21341 RVA: 0x0017928F File Offset: 0x0017748F
			internal static void AutoGeneratedStaticCollectObjectsSmugglersIssue(object o, List<object> collectedObjects)
			{
				((SmugglersIssueBehavior.SmugglersIssue)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x0600535E RID: 21342 RVA: 0x0017929D File Offset: 0x0017749D
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
				collectedObjects.Add(this._targetSettlement);
				collectedObjects.Add(this._originSettlement);
			}

			// Token: 0x0600535F RID: 21343 RVA: 0x001792BE File Offset: 0x001774BE
			internal static object AutoGeneratedGetMemberValue_targetSettlement(object o)
			{
				return ((SmugglersIssueBehavior.SmugglersIssue)o)._targetSettlement;
			}

			// Token: 0x06005360 RID: 21344 RVA: 0x001792CB File Offset: 0x001774CB
			internal static object AutoGeneratedGetMemberValue_originSettlement(object o)
			{
				return ((SmugglersIssueBehavior.SmugglersIssue)o)._originSettlement;
			}

			// Token: 0x170011AD RID: 4525
			// (get) Token: 0x06005361 RID: 21345 RVA: 0x001792D8 File Offset: 0x001774D8
			public override bool IsThereAlternativeSolution
			{
				get
				{
					return true;
				}
			}

			// Token: 0x170011AE RID: 4526
			// (get) Token: 0x06005362 RID: 21346 RVA: 0x001792DB File Offset: 0x001774DB
			public override bool IsThereLordSolution
			{
				get
				{
					return false;
				}
			}

			// Token: 0x170011AF RID: 4527
			// (get) Token: 0x06005363 RID: 21347 RVA: 0x001792DE File Offset: 0x001774DE
			protected override bool IssueQuestCanBeDuplicated
			{
				get
				{
					return false;
				}
			}

			// Token: 0x170011B0 RID: 4528
			// (get) Token: 0x06005364 RID: 21348 RVA: 0x001792E1 File Offset: 0x001774E1
			protected override int RewardGold
			{
				get
				{
					return (int)(750f + 3000f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x06005365 RID: 21349 RVA: 0x001792F8 File Offset: 0x001774F8
			public SmugglersIssue(Hero issueOwner) : base(issueOwner, CampaignTime.DaysFromNow(30f))
			{
				SmugglersIssueBehavior.SmugglersIssue <>4__this = this;
				this._targetSettlement = issueOwner.Clan.Settlements.FirstOrDefaultQ((Settlement settlement) => settlement.Owner == issueOwner && settlement.IsTown);
				this._originSettlement = SettlementHelper.FindNearestTown((Settlement town) => town != <>4__this._targetSettlement, this._targetSettlement);
			}

			// Token: 0x170011B1 RID: 4529
			// (get) Token: 0x06005366 RID: 21350 RVA: 0x00179373 File Offset: 0x00177573
			public override TextObject IssueBriefByIssueGiver
			{
				get
				{
					TextObject textObject = new TextObject("{=bZQQPtJr}{TARGET_SETTLEMENT} has a problem with smugglers. We depend on tariffs for income. People complain, but if we don't collect, then there's no money to keep up the walls and pay the garrison, and believe me if an enemy army came around and pillaged the place because it wasn't defended properly, they'd complain about that too.", null);
					textObject.SetTextVariable("TARGET_SETTLEMENT", this._targetSettlement.Name);
					return textObject;
				}
			}

			// Token: 0x170011B2 RID: 4530
			// (get) Token: 0x06005367 RID: 21351 RVA: 0x00179397 File Offset: 0x00177597
			public override TextObject IssueAcceptByPlayer
			{
				get
				{
					return new TextObject("{=088shjNR}Go on...", null);
				}
			}

			// Token: 0x170011B3 RID: 4531
			// (get) Token: 0x06005368 RID: 21352 RVA: 0x001793A4 File Offset: 0x001775A4
			public override TextObject IssueAlternativeSolutionExplanationByIssueGiver
			{
				get
				{
					TextObject textObject = new TextObject("{=84x0gfUf}I would prefer it if you attended to this yourself. But if you have any companions who can handle a force of {REQUIRED_TROOP_AMOUNT} men, one of them can take care of it.", null);
					textObject.SetTextVariable("REQUIRED_TROOP_AMOUNT", base.GetTotalAlternativeSolutionNeededMenCount());
					return textObject;
				}
			}

			// Token: 0x170011B4 RID: 4532
			// (get) Token: 0x06005369 RID: 21353 RVA: 0x001793C3 File Offset: 0x001775C3
			public override TextObject IssueAlternativeSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=tbR8HmFc}No need to worry, I will have my men attend to the matter immediately.", null);
				}
			}

			// Token: 0x170011B5 RID: 4533
			// (get) Token: 0x0600536A RID: 21354 RVA: 0x001793D0 File Offset: 0x001775D0
			public override TextObject IssueQuestSolutionExplanationByIssueGiver
			{
				get
				{
					TextObject textObject = new TextObject("{=9jJ0QQYm}I think the reason we have it so bad here is because one gang in particular has good contacts both in {TARGET_SETTLEMENT} and in {ORIGIN_SETTLEMENT}. They've so far managed to elude me, but if you patrol the area between the two cities, you might have better luck. And look - I'd prefer it if you brought them to justice, but if you can persuade them to move elsewhere, I'd settle for that too.", null);
					textObject.SetTextVariable("TARGET_SETTLEMENT", this._targetSettlement.Name);
					textObject.SetTextVariable("ORIGIN_SETTLEMENT", this._originSettlement.Name);
					return textObject;
				}
			}

			// Token: 0x170011B6 RID: 4534
			// (get) Token: 0x0600536B RID: 21355 RVA: 0x0017940B File Offset: 0x0017760B
			public override TextObject IssueQuestSolutionAcceptByPlayer
			{
				get
				{
					return new TextObject("{=acqSONrT}I will handle these smugglers myself.", null);
				}
			}

			// Token: 0x170011B7 RID: 4535
			// (get) Token: 0x0600536C RID: 21356 RVA: 0x00179418 File Offset: 0x00177618
			public override TextObject IssueAlternativeSolutionResponseByIssueGiver
			{
				get
				{
					return new TextObject("{=g8qb3Ame}Thank you.", null);
				}
			}

			// Token: 0x170011B8 RID: 4536
			// (get) Token: 0x0600536D RID: 21357 RVA: 0x00179425 File Offset: 0x00177625
			public override TextObject IssueDiscussAlternativeSolution
			{
				get
				{
					return new TextObject("{=RZdL3Mbt}I'm sure your men will take care of those smugglers in no time. I await your good news.", null);
				}
			}

			// Token: 0x170011B9 RID: 4537
			// (get) Token: 0x0600536E RID: 21358 RVA: 0x00179432 File Offset: 0x00177632
			public override TextObject Title
			{
				get
				{
					TextObject textObject = new TextObject("{=Gop9Khfk}Smugglers of {TARGET_CITY}", null);
					textObject.SetTextVariable("TARGET_CITY", this._targetSettlement.Name);
					return textObject;
				}
			}

			// Token: 0x170011BA RID: 4538
			// (get) Token: 0x0600536F RID: 21359 RVA: 0x00179458 File Offset: 0x00177658
			public override TextObject Description
			{
				get
				{
					TextObject textObject = new TextObject("{=pS8Iqeja}{QUEST_GIVER.LINK} is having problems with smugglers in {ORIGIN_CITY}. {?QUEST_GIVER.GENDER}She{?}He{\\?} said that they get their goods from {TARGET_CITY}.", null);
					textObject.SetTextVariable("TARGET_CITY", this._targetSettlement.Name);
					textObject.SetTextVariable("ORIGIN_CITY", this._originSettlement.Name);
					textObject.SetCharacterProperties("QUEST_GIVER", base.IssueOwner.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x170011BB RID: 4539
			// (get) Token: 0x06005370 RID: 21360 RVA: 0x001794B8 File Offset: 0x001776B8
			protected override TextObject AlternativeSolutionStartLog
			{
				get
				{
					TextObject textObject = new TextObject("{=bGERUWEr}{ISSUE_GIVER.LINK} {?ISSUE_GIVER.GENDER}lady{?}lord{\\?} of {TARGET_SETTLEMENT} told you that {?ISSUE_GIVER.GENDER}she{?}he{\\?} has been having issues with smugglers running between {TARGET_SETTLEMENT} and {ORIGIN_SETTLEMENT}. You decided to send {COMPANION.LINK} with {TROOP_COUNT} men to find the smugglers. They should return after {RETURN_DAYS} days.", null);
					textObject.SetCharacterProperties("ISSUE_GIVER", base.IssueOwner.CharacterObject, false);
					textObject.SetCharacterProperties("COMPANION", base.AlternativeSolutionHero.CharacterObject, false);
					textObject.SetTextVariable("TARGET_SETTLEMENT", this._targetSettlement.EncyclopediaLinkWithName);
					textObject.SetTextVariable("ORIGIN_SETTLEMENT", this._originSettlement.EncyclopediaLinkWithName);
					textObject.SetTextVariable("TROOP_COUNT", this.AlternativeSolutionSentTroops.TotalManCount - 1);
					textObject.SetTextVariable("RETURN_DAYS", base.GetTotalAlternativeSolutionDurationInDays());
					return textObject;
				}
			}

			// Token: 0x170011BC RID: 4540
			// (get) Token: 0x06005371 RID: 21361 RVA: 0x00179557 File Offset: 0x00177757
			public override TextObject IssueAlternativeSolutionSuccessLog
			{
				get
				{
					TextObject textObject = new TextObject("{=QhyB7MX0}Your companion {COMPANION.LINK} and your men return with the news of their success. They dispersed the smugglers as promised to {QUEST_GIVER.LINK}.", null);
					textObject.SetCharacterProperties("COMPANION", base.AlternativeSolutionHero.CharacterObject, false);
					textObject.SetCharacterProperties("QUEST_GIVER", base.IssueOwner.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x170011BD RID: 4541
			// (get) Token: 0x06005372 RID: 21362 RVA: 0x00179592 File Offset: 0x00177792
			public override TextObject IssueAlternativeSolutionFailLog
			{
				get
				{
					TextObject textObject = new TextObject("{=ExRIMXDV}Your men failed to get rid of the smugglers as you told {QUEST_GIVER.LINK} you would do.", null);
					textObject.SetCharacterProperties("QUEST_GIVER", base.IssueOwner.CharacterObject, false);
					return textObject;
				}
			}

			// Token: 0x170011BE RID: 4542
			// (get) Token: 0x06005373 RID: 21363 RVA: 0x001795B6 File Offset: 0x001777B6
			protected override int CompanionSkillRewardXP
			{
				get
				{
					return 500 + (int)(1000f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x170011BF RID: 4543
			// (get) Token: 0x06005374 RID: 21364 RVA: 0x001795CB File Offset: 0x001777CB
			public override int AlternativeSolutionBaseNeededMenCount
			{
				get
				{
					return (int)(10f + 20f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x170011C0 RID: 4544
			// (get) Token: 0x06005375 RID: 21365 RVA: 0x001795E0 File Offset: 0x001777E0
			protected override int AlternativeSolutionBaseDurationInDaysInternal
			{
				get
				{
					return (int)(7f + 10f * base.IssueDifficultyMultiplier);
				}
			}

			// Token: 0x170011C1 RID: 4545
			// (get) Token: 0x06005376 RID: 21366 RVA: 0x001795F5 File Offset: 0x001777F5
			public override IssueBase.AlternativeSolutionScaleFlag AlternativeSolutionScaleFlags
			{
				get
				{
					return IssueBase.AlternativeSolutionScaleFlag.Casualties | IssueBase.AlternativeSolutionScaleFlag.FailureRisk;
				}
			}

			// Token: 0x06005377 RID: 21367 RVA: 0x001795FC File Offset: 0x001777FC
			public override ValueTuple<SkillObject, int> GetAlternativeSolutionSkill(Hero hero)
			{
				List<SkillObject> alternativeSolutionMeleeSkills = QuestHelper.GetAlternativeSolutionMeleeSkills();
				alternativeSolutionMeleeSkills.Add(DefaultSkills.Scouting);
				return new ValueTuple<SkillObject, int>(alternativeSolutionMeleeSkills.MaxBy((SkillObject skill) => hero.GetSkillValue(skill)), 150);
			}

			// Token: 0x06005378 RID: 21368 RVA: 0x00179641 File Offset: 0x00177841
			public override bool AlternativeSolutionCondition(out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(MobileParty.MainParty.MemberRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false);
			}

			// Token: 0x06005379 RID: 21369 RVA: 0x00179662 File Offset: 0x00177862
			protected override void AlternativeSolutionEndWithSuccessConsequence()
			{
				GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, this.RewardGold, false);
				this.RelationshipChangeWithIssueOwner = 10;
				this._targetSettlement.Town.Security += 10f;
			}

			// Token: 0x0600537A RID: 21370 RVA: 0x0017969A File Offset: 0x0017789A
			public override bool DoTroopsSatisfyAlternativeSolution(TroopRoster troopRoster, out TextObject explanation)
			{
				explanation = TextObject.Empty;
				return QuestHelper.CheckRosterForAlternativeSolution(troopRoster, base.GetTotalAlternativeSolutionNeededMenCount(), ref explanation, 2, false);
			}

			// Token: 0x0600537B RID: 21371 RVA: 0x001796B2 File Offset: 0x001778B2
			public override IssueBase.IssueFrequency GetFrequency()
			{
				return IssueBase.IssueFrequency.Rare;
			}

			// Token: 0x0600537C RID: 21372 RVA: 0x001796B5 File Offset: 0x001778B5
			public override bool IssueStayAliveConditions()
			{
				return base.IssueOwner.IsAlive && this._targetSettlement.Owner == base.IssueOwner && this._targetSettlement.Town.Security < 80f;
			}

			// Token: 0x0600537D RID: 21373 RVA: 0x001796F0 File Offset: 0x001778F0
			protected override bool CanPlayerTakeQuestConditions(Hero issueGiver, out IssueBase.PreconditionFlags flag, out Hero relationHero, out SkillObject skill)
			{
				flag = IssueBase.PreconditionFlags.None;
				relationHero = issueGiver;
				skill = null;
				if (issueGiver.GetRelationWithPlayer() < -10f)
				{
					flag |= IssueBase.PreconditionFlags.Relation;
				}
				if (FactionManager.IsAtWarAgainstFaction(issueGiver.MapFaction, Hero.MainHero.MapFaction))
				{
					flag |= IssueBase.PreconditionFlags.AtWar;
				}
				if (MobileParty.MainParty.MemberRoster.TotalManCount <= 10)
				{
					flag |= IssueBase.PreconditionFlags.NotEnoughTroops;
				}
				return flag == IssueBase.PreconditionFlags.None;
			}

			// Token: 0x0600537E RID: 21374 RVA: 0x0017975A File Offset: 0x0017795A
			protected override float GetIssueEffectAmountInternal(IssueEffect issueEffect)
			{
				if (issueEffect == DefaultIssueEffects.SettlementLoyalty)
				{
					return -0.1f;
				}
				if (issueEffect == DefaultIssueEffects.SettlementSecurity)
				{
					return -0.5f;
				}
				return 0f;
			}

			// Token: 0x0600537F RID: 21375 RVA: 0x0017977D File Offset: 0x0017797D
			protected override void CompleteIssueWithTimedOutConsequences()
			{
			}

			// Token: 0x06005380 RID: 21376 RVA: 0x0017977F File Offset: 0x0017797F
			protected override void OnGameLoad()
			{
			}

			// Token: 0x06005381 RID: 21377 RVA: 0x00179781 File Offset: 0x00177981
			protected override QuestBase GenerateIssueQuest(string questId)
			{
				return new SmugglersIssueBehavior.SmugglersIssueQuest(questId, base.IssueOwner, this._targetSettlement, this._originSettlement, base.IssueDifficultyMultiplier, CampaignTime.DaysFromNow(20f), this.RewardGold);
			}

			// Token: 0x06005382 RID: 21378 RVA: 0x001797B1 File Offset: 0x001779B1
			protected override void HourlyTick()
			{
			}

			// Token: 0x04001B22 RID: 6946
			[SaveableField(1)]
			private readonly Settlement _targetSettlement;

			// Token: 0x04001B23 RID: 6947
			[SaveableField(2)]
			private readonly Settlement _originSettlement;

			// Token: 0x04001B24 RID: 6948
			private const int IssueDuration = 30;

			// Token: 0x04001B25 RID: 6949
			private const int QuestTimeLimit = 20;

			// Token: 0x04001B26 RID: 6950
			private const int CompanionRequiredSkillLevel = 150;

			// Token: 0x04001B27 RID: 6951
			private const int AlternativeSolutionMinimumTroopLevel = 2;

			// Token: 0x04001B28 RID: 6952
			private const int SuccessRelationBonus = 10;

			// Token: 0x04001B29 RID: 6953
			private const int SuccessSecurityBonus = 10;

			// Token: 0x04001B2A RID: 6954
			private const int TroopsRequiredForQuest = 10;
		}

		// Token: 0x02000674 RID: 1652
		public class SmugglersIssueQuest : QuestBase
		{
			// Token: 0x06005383 RID: 21379 RVA: 0x001797B3 File Offset: 0x001779B3
			internal static void AutoGeneratedStaticCollectObjectsSmugglersIssueQuest(object o, List<object> collectedObjects)
			{
				((SmugglersIssueBehavior.SmugglersIssueQuest)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
			}

			// Token: 0x06005384 RID: 21380 RVA: 0x001797C1 File Offset: 0x001779C1
			protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
			{
				base.AutoGeneratedInstanceCollectObjects(collectedObjects);
				collectedObjects.Add(this._targetSettlement);
				collectedObjects.Add(this._originSettlement);
				collectedObjects.Add(this._smugglerParty);
			}

			// Token: 0x06005385 RID: 21381 RVA: 0x001797EE File Offset: 0x001779EE
			internal static object AutoGeneratedGetMemberValue_targetSettlement(object o)
			{
				return ((SmugglersIssueBehavior.SmugglersIssueQuest)o)._targetSettlement;
			}

			// Token: 0x06005386 RID: 21382 RVA: 0x001797FB File Offset: 0x001779FB
			internal static object AutoGeneratedGetMemberValue_originSettlement(object o)
			{
				return ((SmugglersIssueBehavior.SmugglersIssueQuest)o)._originSettlement;
			}

			// Token: 0x06005387 RID: 21383 RVA: 0x00179808 File Offset: 0x00177A08
			internal static object AutoGeneratedGetMemberValue_smugglerParty(object o)
			{
				return ((SmugglersIssueBehavior.SmugglersIssueQuest)o)._smugglerParty;
			}

			// Token: 0x06005388 RID: 21384 RVA: 0x00179815 File Offset: 0x00177A15
			internal static object AutoGeneratedGetMemberValue_issueDifficulty(object o)
			{
				return ((SmugglersIssueBehavior.SmugglersIssueQuest)o)._issueDifficulty;
			}

			// Token: 0x06005389 RID: 21385 RVA: 0x00179827 File Offset: 0x00177A27
			internal static object AutoGeneratedGetMemberValue_smugglerSettlementWaitCounter(object o)
			{
				return ((SmugglersIssueBehavior.SmugglersIssueQuest)o)._smugglerSettlementWaitCounter;
			}

			// Token: 0x170011C2 RID: 4546
			// (get) Token: 0x0600538A RID: 21386 RVA: 0x00179839 File Offset: 0x00177A39
			private int BribeAmount
			{
				get
				{
					return (int)((float)this.RewardGold * 0.75f);
				}
			}

			// Token: 0x170011C3 RID: 4547
			// (get) Token: 0x0600538B RID: 21387 RVA: 0x00179849 File Offset: 0x00177A49
			private int SmugglerPartySize
			{
				get
				{
					return (int)((float)MobileParty.MainParty.MemberRoster.TotalManCount * 0.8f * this._issueDifficulty);
				}
			}

			// Token: 0x170011C4 RID: 4548
			// (get) Token: 0x0600538C RID: 21388 RVA: 0x00179869 File Offset: 0x00177A69
			public override bool IsRemainingTimeHidden
			{
				get
				{
					return false;
				}
			}

			// Token: 0x170011C5 RID: 4549
			// (get) Token: 0x0600538D RID: 21389 RVA: 0x0017986C File Offset: 0x00177A6C
			private TextObject QuestStartedLog
			{
				get
				{
					TextObject textObject = new TextObject("{=R98gwuK1}{QUEST_GIVER.LINK} {?QUEST_GIVER.GENDER}lady{?}lord{\\?} of {TARGET_SETTLEMENT} told you that {?QUEST_GIVER.GENDER}she{?}he{\\?} has been having issues with smugglers running between {TARGET_SETTLEMENT} and {ORIGIN_SETTLEMENT}. You promised to track the smugglers down and chase them away from {TARGET_SETTLEMENT}.", null);
					textObject.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
					textObject.SetTextVariable("TARGET_SETTLEMENT", this._targetSettlement.EncyclopediaLinkWithName);
					textObject.SetTextVariable("ORIGIN_SETTLEMENT", this._originSettlement.EncyclopediaLinkWithName);
					return textObject;
				}
			}

			// Token: 0x170011C6 RID: 4550
			// (get) Token: 0x0600538E RID: 21390 RVA: 0x001798CC File Offset: 0x00177ACC
			private TextObject QuestCanceledWarDeclaredLog
			{
				get
				{
					TextObject textObject = new TextObject("{=vW6kBki9}Your clan is now at war with {QUEST_GIVER.LINK}'s realm. Your agreement with {QUEST_GIVER.LINK} is canceled.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170011C7 RID: 4551
			// (get) Token: 0x0600538F RID: 21391 RVA: 0x00179900 File Offset: 0x00177B00
			private TextObject QuestCanceledSettlementOwnerChangedLog
			{
				get
				{
					TextObject textObject = new TextObject("{=xSaVRIN7}{QUEST_GIVER.LINK} has lost the ownership of {TARGET_CITY}. Your agreement with {QUEST_GIVER.LINK} is canceled.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					textObject.SetTextVariable("TARGET_CITY", this._targetSettlement.EncyclopediaLinkWithName);
					return textObject;
				}
			}

			// Token: 0x170011C8 RID: 4552
			// (get) Token: 0x06005390 RID: 21392 RVA: 0x0017994C File Offset: 0x00177B4C
			private TextObject QuestFailedLog
			{
				get
				{
					TextObject textObject = new TextObject("{=QB4bKAVR}You failed to get rid of the smugglers as you told {QUEST_GIVER.LINK} you would do.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170011C9 RID: 4553
			// (get) Token: 0x06005391 RID: 21393 RVA: 0x00179980 File Offset: 0x00177B80
			private TextObject QuestSuccessWithFightLog
			{
				get
				{
					TextObject textObject = new TextObject("{=7N8jdPdV}You got rid of the smugglers as you promised {QUEST_GIVER.LINK} you would do.", null);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170011CA RID: 4554
			// (get) Token: 0x06005392 RID: 21394 RVA: 0x001799B4 File Offset: 0x00177BB4
			private TextObject QuestSuccessWithPersuasionLog
			{
				get
				{
					TextObject textObject = new TextObject("{=84ZwbJaq}You persuaded the smugglers to move away from {TARGET_SETTLEMENT}. They are now far away from {TARGET_SETTLEMENT} and {QUEST_GIVER.LINK} is satisfied.", null);
					textObject.SetTextVariable("TARGET_SETTLEMENT", this._targetSettlement.Name);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170011CB RID: 4555
			// (get) Token: 0x06005393 RID: 21395 RVA: 0x00179A00 File Offset: 0x00177C00
			private TextObject QuestSuccessWithBribeLog
			{
				get
				{
					TextObject textObject = new TextObject("{=Ici6us1S}You paid the smugglers to move away from {TARGET_SETTLEMENT}. They are now far away and {QUEST_GIVER.LINK} is satisfied.", null);
					textObject.SetTextVariable("TARGET_SETTLEMENT", this._targetSettlement.Name);
					StringHelpers.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, textObject, false);
					return textObject;
				}
			}

			// Token: 0x170011CC RID: 4556
			// (get) Token: 0x06005394 RID: 21396 RVA: 0x00179A49 File Offset: 0x00177C49
			public override TextObject Title
			{
				get
				{
					TextObject textObject = new TextObject("{=Gop9Khfk}Smugglers of {TARGET_CITY}", null);
					textObject.SetTextVariable("TARGET_CITY", this._targetSettlement.Name);
					return textObject;
				}
			}

			// Token: 0x06005395 RID: 21397 RVA: 0x00179A70 File Offset: 0x00177C70
			public SmugglersIssueQuest(string questId, Hero questGiver, Settlement targetSettlement, Settlement originSettlement, float issueDifficulty, CampaignTime duration, int rewardGold) : base(questId, questGiver, duration, rewardGold)
			{
				this._targetSettlement = targetSettlement;
				this._originSettlement = originSettlement;
				this._issueDifficulty = issueDifficulty;
				this.SetDialogs();
				base.InitializeQuestOnCreation();
			}

			// Token: 0x06005396 RID: 21398 RVA: 0x00179AD8 File Offset: 0x00177CD8
			protected override void SetDialogs()
			{
				TextObject npcText = new TextObject("{=g8qb3Ame}Thank you.", null);
				TextObject npcText2 = new TextObject("{=KLkaBjy7}I'm glad you're taking care of those smugglers.", null);
				this.OfferDialogFlow = DialogFlow.CreateDialogFlow("issue_classic_quest_start", 100).NpcLine(npcText, null, null).Condition(() => Hero.OneToOneConversationHero == base.QuestGiver).Consequence(new ConversationSentence.OnConsequenceDelegate(this.QuestAcceptedConsequences)).CloseDialog();
				this.DiscussDialogFlow = DialogFlow.CreateDialogFlow("quest_discuss", 100).NpcLine(npcText2, null, null).Condition(() => Hero.OneToOneConversationHero == base.QuestGiver).Consequence(delegate
				{
					Campaign.Current.ConversationManager.ConversationEndOneShot += MapEventHelper.OnConversationEnd;
				}).CloseDialog();
				DialogFlow smugglerPartyDialog = this.GetSmugglerPartyDialog();
				this.AddPersuasionDialogs(smugglerPartyDialog);
				Campaign.Current.ConversationManager.AddDialogFlow(smugglerPartyDialog, this);
			}

			// Token: 0x06005397 RID: 21399 RVA: 0x00179BB4 File Offset: 0x00177DB4
			private DialogFlow GetSmugglerPartyDialog()
			{
				TextObject npcText = new TextObject("{=EUJaTe2v}Who are you? What do you want from us?", null);
				TextObject textObject = new TextObject("{=4iEQr3il}Halt. You're wanted by the authorities in {TARGET_SETTLEMENT} for smuggling.", null);
				textObject.SetTextVariable("TARGET_SETTLEMENT", this._targetSettlement.Name);
				TextObject npcText2 = new TextObject("{=vo8fmqwC}Hey... We're just honest traders here, trying to get by in these hard times.", null);
				TextObject playerText = new TextObject("{=qa3xzdbO}I think not. I'm going to give you one chance to leave this district, and never come back under pain of death.", null);
				TextObject npcText3 = new TextObject("{=BRaGcALd}Hah! Now why would we do that?", null);
				TextObject text = new TextObject("{=Ga5E2saO}Because it would be easier to work elsewhere.", null);
				TextObject text2 = new TextObject("{=722uabab}Because if you don't, I'll cut you down right here and now.", null);
				TextObject npcText4 = new TextObject("{=8dys8maS}Oh is that so? This will be fun.", null);
				TextObject text3 = new TextObject("{=WwzniBzk}Because I'll pay you. Silver is better than death, isn't it?", null);
				TextObject textObject2 = new TextObject("{=aABDmDJk}Heh, I like the way you think. Fine. It's become too risky around these parts anyway. You won't see us near {TARGET_SETTLEMENT} again.", null);
				textObject2.SetTextVariable("TARGET_SETTLEMENT", this._targetSettlement.Name);
				return DialogFlow.CreateDialogFlow("start", 125).NpcLine(npcText, null, null).Condition(() => this._smugglerParty != null && CharacterObject.OneToOneConversationCharacter == ConversationHelper.GetConversationCharacterPartyLeader(this._smugglerParty.Party)).Consequence(delegate
				{
					this._task = this.GetPersuasionTask();
				}).PlayerLine(textObject, null).NpcLine(npcText2, null, null).PlayerLine(playerText, null).NpcLine(npcText3, null, null).BeginPlayerOptions().PlayerOption(text, null).GotoDialogState("start_smugglers_persuasion").PlayerOption(text2, null).NpcLine(npcText4, null, null).Consequence(delegate
				{
					EncounterManager.StartPartyEncounter(PartyBase.MainParty, this._smugglerParty.Party);
					Campaign.Current.GameMenuManager.SetNextMenu("encounter");
				}).CloseDialog().PlayerOption(text3, null).ClickableCondition(new ConversationSentence.OnClickableConditionDelegate(this.BribeCondition)).NpcLine(textObject2, null, null).Consequence(new ConversationSentence.OnConsequenceDelegate(this.SucceedQuestWithBribe)).CloseDialog().EndPlayerOptions().CloseDialog();
			}

			// Token: 0x06005398 RID: 21400 RVA: 0x00179D44 File Offset: 0x00177F44
			private PersuasionTask GetPersuasionTask()
			{
				PersuasionTask persuasionTask = new PersuasionTask(0);
				persuasionTask.FinalFailLine = new TextObject("{=iRarm6f7}We are not going anywhere friend. You're going to have to fight for your silver today.", null);
				persuasionTask.TryLaterLine = TextObject.Empty;
				persuasionTask.SpokenLine = new TextObject("{=xnT03Yv0}I'm listening.", null);
				TextObject textObject = new TextObject("{=gtY7QuX0}{QUEST_GIVER.LINK} is on to you. I can guarantee you the time of easy pickings and low risk is over.", null);
				textObject.SetCharacterProperties("QUEST_GIVER", base.QuestGiver.CharacterObject, false);
				TextObject textObject2 = new TextObject("{=T7bMlcj3}Prices in {TARGET_SETTLEMENT} are down these days. Enterprising lads like you can do better elsewhere.", null);
				textObject2.SetTextVariable("TARGET_SETTLEMENT", this._targetSettlement.Name);
				TextObject line = new TextObject("{=6cbdm02F}Because if you make me angry, you'll wish you were dead long before I actually kill you.", null);
				PersuasionOptionArgs option = new PersuasionOptionArgs(DefaultSkills.Roguery, DefaultTraits.Valor, TraitEffect.Positive, PersuasionArgumentStrength.Hard, true, textObject, null, false, false, false);
				PersuasionOptionArgs option2 = new PersuasionOptionArgs(DefaultSkills.Trade, DefaultTraits.Calculating, TraitEffect.Positive, PersuasionArgumentStrength.VeryEasy, false, textObject2, null, false, false, false);
				PersuasionOptionArgs option3 = new PersuasionOptionArgs(DefaultSkills.Roguery, DefaultTraits.Mercy, TraitEffect.Negative, PersuasionArgumentStrength.VeryHard, false, line, null, false, false, false);
				persuasionTask.AddOptionToTask(option);
				persuasionTask.AddOptionToTask(option2);
				persuasionTask.AddOptionToTask(option3);
				return persuasionTask;
			}

			// Token: 0x06005399 RID: 21401 RVA: 0x00179E38 File Offset: 0x00178038
			private void AddPersuasionDialogs(DialogFlow dialog)
			{
				dialog.AddDialogLine("smugglers_persuasion_check_accepted", "start_smugglers_persuasion", "smugglers_persuasion_start_reservation", "{=6P1ruzsC}Maybe...", new ConversationSentence.OnConditionDelegate(this.persuasion_start_with_smugglers_on_condition), new ConversationSentence.OnConsequenceDelegate(this.persuasion_start_with_smugglers_on_consequence), this, 100, null, null, null);
				dialog.AddDialogLine("smugglers_persuasion_rejected", "smugglers_persuasion_start_reservation", "close_window", "{=!}{FAILED_PERSUASION_LINE}", new ConversationSentence.OnConditionDelegate(this.persuasion_failed_with_smugglers_on_condition), new ConversationSentence.OnConsequenceDelegate(this.persuasion_rejected_with_smugglers_on_consequence), this, 100, null, null, null);
				dialog.AddDialogLine("smugglers_persuasion_attempt", "smugglers_persuasion_start_reservation", "smugglers_persuasion_select_option", "{=wM77S68a}What's there to discuss?", () => !this.persuasion_failed_with_smugglers_on_condition(), null, this, 100, null, null, null);
				dialog.AddDialogLine("smugglers_persuasion_success", "smugglers_persuasion_start_reservation", "close_window", "{=m61UnySr}Yeah, you make a good point. If you find us, others can too. We will move elsewhere.", new ConversationSentence.OnConditionDelegate(ConversationManager.GetPersuasionProgressSatisfied), new ConversationSentence.OnConsequenceDelegate(this.persuasion_complete_with_smugglers_on_consequence), this, 200, null, null, null);
				string id = "smugglers_persuasion_select_option_1";
				string inputToken = "smugglers_persuasion_select_option";
				string outputToken = "smugglers_persuasion_selected_option_response";
				string text = "{=!}{smugglers_PERSUADE_ATTEMPT_1}";
				ConversationSentence.OnConditionDelegate conditionDelegate = new ConversationSentence.OnConditionDelegate(this.smugglers_persuasion_select_option_1_on_condition);
				ConversationSentence.OnConsequenceDelegate consequenceDelegate = new ConversationSentence.OnConsequenceDelegate(this.smugglers_persuasion_select_option_1_on_consequence);
				ConversationSentence.OnPersuasionOptionDelegate persuasionOptionDelegate = new ConversationSentence.OnPersuasionOptionDelegate(this.smugglers_persuasion_setup_option_1);
				ConversationSentence.OnClickableConditionDelegate clickableConditionDelegate = new ConversationSentence.OnClickableConditionDelegate(this.smugglers_persuasion_clickable_option_1_on_condition);
				dialog.AddPlayerLine(id, inputToken, outputToken, text, conditionDelegate, consequenceDelegate, this, 100, clickableConditionDelegate, persuasionOptionDelegate, null, null);
				string id2 = "smugglers_persuasion_select_option_2";
				string inputToken2 = "smugglers_persuasion_select_option";
				string outputToken2 = "smugglers_persuasion_selected_option_response";
				string text2 = "{=!}{smugglers_PERSUADE_ATTEMPT_2}";
				ConversationSentence.OnConditionDelegate conditionDelegate2 = new ConversationSentence.OnConditionDelegate(this.smugglers_persuasion_select_option_2_on_condition);
				ConversationSentence.OnConsequenceDelegate consequenceDelegate2 = new ConversationSentence.OnConsequenceDelegate(this.smugglers_persuasion_select_option_2_on_consequence);
				persuasionOptionDelegate = new ConversationSentence.OnPersuasionOptionDelegate(this.smugglers_persuasion_setup_option_2);
				clickableConditionDelegate = new ConversationSentence.OnClickableConditionDelegate(this.smugglers_persuasion_clickable_option_2_on_condition);
				dialog.AddPlayerLine(id2, inputToken2, outputToken2, text2, conditionDelegate2, consequenceDelegate2, this, 100, clickableConditionDelegate, persuasionOptionDelegate, null, null);
				string id3 = "smugglers_persuasion_select_option_3";
				string inputToken3 = "smugglers_persuasion_select_option";
				string outputToken3 = "smugglers_persuasion_selected_option_response";
				string text3 = "{=!}{smugglers_PERSUADE_ATTEMPT_3}";
				ConversationSentence.OnConditionDelegate conditionDelegate3 = new ConversationSentence.OnConditionDelegate(this.smugglers_persuasion_select_option_3_on_condition);
				ConversationSentence.OnConsequenceDelegate consequenceDelegate3 = new ConversationSentence.OnConsequenceDelegate(this.smugglers_persuasion_select_option_3_on_consequence);
				persuasionOptionDelegate = new ConversationSentence.OnPersuasionOptionDelegate(this.smugglers_persuasion_setup_option_3);
				clickableConditionDelegate = new ConversationSentence.OnClickableConditionDelegate(this.smugglers_persuasion_clickable_option_3_on_condition);
				dialog.AddPlayerLine(id3, inputToken3, outputToken3, text3, conditionDelegate3, consequenceDelegate3, this, 100, clickableConditionDelegate, persuasionOptionDelegate, null, null);
				dialog.AddDialogLine("smugglers_persuasion_select_option_reaction", "smugglers_persuasion_selected_option_response", "smugglers_persuasion_start_reservation", "{=!}{PERSUASION_REACTION}", new ConversationSentence.OnConditionDelegate(this.smugglers_persuasion_selected_option_response_on_condition), new ConversationSentence.OnConsequenceDelegate(this.smugglers_persuasion_selected_option_response_on_consequence), this, 100, null, null, null);
			}

			// Token: 0x0600539A RID: 21402 RVA: 0x0017A056 File Offset: 0x00178256
			private void persuasion_start_with_smugglers_on_consequence()
			{
				ConversationManager.StartPersuasion(2f, 1f, 0f, 2f, 2f, 0f, PersuasionDifficulty.MediumHard);
			}

			// Token: 0x0600539B RID: 21403 RVA: 0x0017A07C File Offset: 0x0017827C
			private bool persuasion_start_with_smugglers_on_condition()
			{
				return this._smugglerParty != null && CharacterObject.OneToOneConversationCharacter == ConversationHelper.GetConversationCharacterPartyLeader(this._smugglerParty.Party);
			}

			// Token: 0x0600539C RID: 21404 RVA: 0x0017A0A0 File Offset: 0x001782A0
			private bool smugglers_persuasion_selected_option_response_on_condition()
			{
				PersuasionOptionResult item = ConversationManager.GetPersuasionChosenOptions().Last<Tuple<PersuasionOptionArgs, PersuasionOptionResult>>().Item2;
				MBTextManager.SetTextVariable("PERSUASION_REACTION", PersuasionHelper.GetDefaultPersuasionOptionReaction(item), false);
				if (item == PersuasionOptionResult.CriticalFailure)
				{
					this._task.BlockAllOptions();
				}
				return true;
			}

			// Token: 0x0600539D RID: 21405 RVA: 0x0017A0E0 File Offset: 0x001782E0
			private void smugglers_persuasion_selected_option_response_on_consequence()
			{
				Tuple<PersuasionOptionArgs, PersuasionOptionResult> tuple = ConversationManager.GetPersuasionChosenOptions().Last<Tuple<PersuasionOptionArgs, PersuasionOptionResult>>();
				float difficulty = Campaign.Current.Models.PersuasionModel.GetDifficulty(PersuasionDifficulty.MediumHard);
				float moveToNextStageChance;
				float blockRandomOptionChance;
				Campaign.Current.Models.PersuasionModel.GetEffectChances(tuple.Item1, out moveToNextStageChance, out blockRandomOptionChance, difficulty);
				this._task.ApplyEffects(moveToNextStageChance, blockRandomOptionChance);
			}

			// Token: 0x0600539E RID: 21406 RVA: 0x0017A13C File Offset: 0x0017833C
			private bool smugglers_persuasion_select_option_1_on_condition()
			{
				if (this._task.Options.Count > 0)
				{
					TextObject textObject = new TextObject("{=bSo9hKwr}{PERSUASION_OPTION_LINE} {SUCCESS_CHANCE}", null);
					textObject.SetTextVariable("SUCCESS_CHANCE", PersuasionHelper.ShowSuccess(this._task.Options.ElementAt(0), false));
					textObject.SetTextVariable("PERSUASION_OPTION_LINE", this._task.Options.ElementAt(0).Line);
					MBTextManager.SetTextVariable("smugglers_PERSUADE_ATTEMPT_1", textObject, false);
					return true;
				}
				return false;
			}

			// Token: 0x0600539F RID: 21407 RVA: 0x0017A1BC File Offset: 0x001783BC
			private bool smugglers_persuasion_select_option_2_on_condition()
			{
				if (this._task.Options.Count > 1)
				{
					TextObject textObject = new TextObject("{=bSo9hKwr}{PERSUASION_OPTION_LINE} {SUCCESS_CHANCE}", null);
					textObject.SetTextVariable("SUCCESS_CHANCE", PersuasionHelper.ShowSuccess(this._task.Options.ElementAt(1), false));
					textObject.SetTextVariable("PERSUASION_OPTION_LINE", this._task.Options.ElementAt(1).Line);
					MBTextManager.SetTextVariable("smugglers_PERSUADE_ATTEMPT_2", textObject, false);
					return true;
				}
				return false;
			}

			// Token: 0x060053A0 RID: 21408 RVA: 0x0017A23C File Offset: 0x0017843C
			private bool smugglers_persuasion_select_option_3_on_condition()
			{
				if (this._task.Options.Count > 2)
				{
					TextObject textObject = new TextObject("{=bSo9hKwr}{PERSUASION_OPTION_LINE} {SUCCESS_CHANCE}", null);
					textObject.SetTextVariable("SUCCESS_CHANCE", PersuasionHelper.ShowSuccess(this._task.Options.ElementAt(2), false));
					textObject.SetTextVariable("PERSUASION_OPTION_LINE", this._task.Options.ElementAt(2).Line);
					MBTextManager.SetTextVariable("smugglers_PERSUADE_ATTEMPT_3", textObject, false);
					return true;
				}
				return false;
			}

			// Token: 0x060053A1 RID: 21409 RVA: 0x0017A2BC File Offset: 0x001784BC
			private void smugglers_persuasion_select_option_1_on_consequence()
			{
				if (this._task.Options.Count > 0)
				{
					this._task.Options[0].BlockTheOption(true);
				}
			}

			// Token: 0x060053A2 RID: 21410 RVA: 0x0017A2E8 File Offset: 0x001784E8
			private void smugglers_persuasion_select_option_2_on_consequence()
			{
				if (this._task.Options.Count > 1)
				{
					this._task.Options[1].BlockTheOption(true);
				}
			}

			// Token: 0x060053A3 RID: 21411 RVA: 0x0017A314 File Offset: 0x00178514
			private void smugglers_persuasion_select_option_3_on_consequence()
			{
				if (this._task.Options.Count > 2)
				{
					this._task.Options[2].BlockTheOption(true);
				}
			}

			// Token: 0x060053A4 RID: 21412 RVA: 0x0017A340 File Offset: 0x00178540
			private bool persuasion_failed_with_smugglers_on_condition()
			{
				if (this._task.Options.All((PersuasionOptionArgs x) => x.IsBlocked) && !ConversationManager.GetPersuasionProgressSatisfied())
				{
					MBTextManager.SetTextVariable("FAILED_PERSUASION_LINE", this._task.FinalFailLine, false);
					return true;
				}
				return false;
			}

			// Token: 0x060053A5 RID: 21413 RVA: 0x0017A39E File Offset: 0x0017859E
			private PersuasionOptionArgs smugglers_persuasion_setup_option_1()
			{
				return this._task.Options.ElementAt(0);
			}

			// Token: 0x060053A6 RID: 21414 RVA: 0x0017A3B1 File Offset: 0x001785B1
			private PersuasionOptionArgs smugglers_persuasion_setup_option_2()
			{
				return this._task.Options.ElementAt(1);
			}

			// Token: 0x060053A7 RID: 21415 RVA: 0x0017A3C4 File Offset: 0x001785C4
			private PersuasionOptionArgs smugglers_persuasion_setup_option_3()
			{
				return this._task.Options.ElementAt(2);
			}

			// Token: 0x060053A8 RID: 21416 RVA: 0x0017A3D8 File Offset: 0x001785D8
			private bool smugglers_persuasion_clickable_option_1_on_condition(out TextObject hintText)
			{
				hintText = new TextObject("{=9ACJsI6S}Blocked", null);
				if (this._task.Options.Count > 0)
				{
					hintText = (this._task.Options.ElementAt(0).IsBlocked ? hintText : TextObject.Empty);
					return !this._task.Options.ElementAt(0).IsBlocked;
				}
				return false;
			}

			// Token: 0x060053A9 RID: 21417 RVA: 0x0017A444 File Offset: 0x00178644
			private bool smugglers_persuasion_clickable_option_2_on_condition(out TextObject hintText)
			{
				hintText = new TextObject("{=9ACJsI6S}Blocked", null);
				if (this._task.Options.Count > 1)
				{
					hintText = (this._task.Options.ElementAt(1).IsBlocked ? hintText : TextObject.Empty);
					return !this._task.Options.ElementAt(1).IsBlocked;
				}
				return false;
			}

			// Token: 0x060053AA RID: 21418 RVA: 0x0017A4B0 File Offset: 0x001786B0
			private bool smugglers_persuasion_clickable_option_3_on_condition(out TextObject hintText)
			{
				hintText = new TextObject("{=9ACJsI6S}Blocked", null);
				if (this._task.Options.Count > 2)
				{
					hintText = (this._task.Options.ElementAt(2).IsBlocked ? hintText : TextObject.Empty);
					return !this._task.Options.ElementAt(2).IsBlocked;
				}
				return false;
			}

			// Token: 0x060053AB RID: 21419 RVA: 0x0017A51B File Offset: 0x0017871B
			private void persuasion_rejected_with_smugglers_on_consequence()
			{
				PlayerEncounter.LeaveEncounter = false;
				ConversationManager.EndPersuasion();
			}

			// Token: 0x060053AC RID: 21420 RVA: 0x0017A528 File Offset: 0x00178728
			private void persuasion_complete_with_smugglers_on_consequence()
			{
				PlayerEncounter.LeaveEncounter = true;
				ConversationManager.EndPersuasion();
				Campaign.Current.ConversationManager.ConversationEndOneShot += delegate()
				{
					this.SucceedQuest(this.QuestSuccessWithPersuasionLog);
				};
			}

			// Token: 0x060053AD RID: 21421 RVA: 0x0017A550 File Offset: 0x00178750
			private bool BribeCondition(out TextObject explanation)
			{
				if (Hero.MainHero.Gold >= this.BribeAmount)
				{
					explanation = new TextObject("{=FebKjriO}You will give {BRIBE_AMOUNT} denars.", null);
					explanation.SetTextVariable("BRIBE_AMOUNT", this.BribeAmount);
					return true;
				}
				explanation = new TextObject("{=Xy4brTbf}You don't have {BRIBE_AMOUNT} denars.", null);
				explanation.SetTextVariable("BRIBE_AMOUNT", this.BribeAmount);
				return false;
			}

			// Token: 0x060053AE RID: 21422 RVA: 0x0017A5B2 File Offset: 0x001787B2
			private void QuestAcceptedConsequences()
			{
				base.StartQuest();
				base.AddLog(this.QuestStartedLog, false);
				this._smugglerParty = this.CreateSmugglerParty();
				base.AddTrackedObject(this._targetSettlement);
				base.AddTrackedObject(this._originSettlement);
			}

			// Token: 0x060053AF RID: 21423 RVA: 0x0017A5EC File Offset: 0x001787EC
			private MobileParty CreateSmugglerParty()
			{
				TextObject textObject = new TextObject("{=3dhAfC4k}Smugglers of {ORIGIN_SETTLEMENT}", null);
				textObject.SetTextVariable("ORIGIN_SETTLEMENT", this._originSettlement.Name);
				TroopRoster.CreateDummyTroopRoster();
				TroopRoster.CreateDummyTroopRoster();
				string partyMountStringId;
				string partyHarnessStringId;
				this.GetAdditionalVisualsForParty(this._originSettlement.Culture, out partyMountStringId, out partyHarnessStringId);
				Settlement nearestHideoutSettlement = SettlementHelper.FindNearestHideout(null, null);
				int troopLimit = (int)MathF.Clamp((float)MathF.Ceiling((float)MobileParty.MainParty.MemberRoster.TotalManCount * 0.8f), 15f, 35f);
				float customPartyBaseSpeed = MobileParty.MainParty.Speed * 1.1f;
				MobileParty mobileParty = CustomPartyComponent.CreateQuestParty(this._originSettlement.GatePosition, 0.1f, this._originSettlement, textObject, Clan.BanditFactions.FirstOrDefault((Clan faction) => faction.Culture == nearestHideoutSettlement.Culture), this._originSettlement.Culture.CaravanPartyTemplate, null, troopLimit, partyMountStringId, partyHarnessStringId, customPartyBaseSpeed, true);
				CharacterObject @object = MBObjectManager.Instance.GetObject<CharacterObject>("nervous_caravanmaster_" + MBRandom.RandomInt(1, 4));
				mobileParty.MemberRoster.AddToCounts(@object, 1, true, 0, 0, true, -1);
				this.GiveGoodsToParty(mobileParty);
				this.InitializePartyState(mobileParty);
				mobileParty.SetPartyUsedByQuest(true);
				return mobileParty;
			}

			// Token: 0x060053B0 RID: 21424 RVA: 0x0017A730 File Offset: 0x00178930
			private void GetAdditionalVisualsForParty(CultureObject culture, out string mountStringId, out string harnessStringId)
			{
				if (culture.StringId == "aserai" || culture.StringId == "khuzait")
				{
					mountStringId = "camel";
					harnessStringId = ((MBRandom.RandomFloat > 0.5f) ? "camel_saddle_a" : "camel_saddle_b");
					return;
				}
				mountStringId = "mule";
				harnessStringId = ((MBRandom.RandomFloat > 0.5f) ? "mule_load_a" : ((MBRandom.RandomFloat > 0.5f) ? "mule_load_b" : "mule_load_c"));
			}

			// Token: 0x060053B1 RID: 21425 RVA: 0x0017A7B8 File Offset: 0x001789B8
			private void GiveGoodsToParty(MobileParty mobileParty)
			{
				int num = MathF.Ceiling(400f + 3000f * this._issueDifficulty);
				ItemObject @object = MBObjectManager.Instance.GetObject<ItemObject>(this._possibleSmuggledItems.GetRandomElement<string>());
				int number = num / @object.Value;
				mobileParty.ItemRoster.AddToCounts(@object, number);
				mobileParty.ItemRoster.AddToCounts(MBObjectManager.Instance.GetObject<ItemObject>("grain"), MathF.Ceiling(30f + 20f * this._issueDifficulty));
			}

			// Token: 0x060053B2 RID: 21426 RVA: 0x0017A83C File Offset: 0x00178A3C
			private void InitializePartyState(MobileParty mobileParty)
			{
				TextObject customName = new TextObject("{=GTnVcUz9}Smugglers' Party", null);
				mobileParty.InitializeMobilePartyAtPosition(new TroopRoster(mobileParty.Party), new TroopRoster(mobileParty.Party), this._originSettlement.GatePosition);
				mobileParty.SetCustomName(customName);
				mobileParty.Ai.SetDoNotMakeNewDecisions(true);
				mobileParty.IgnoreByOtherPartiesTill(CampaignTime.Never);
				mobileParty.SetCustomHomeSettlement(this._originSettlement);
				SetPartyAiAction.GetActionForVisitingSettlement(mobileParty, this._targetSettlement);
			}

			// Token: 0x060053B3 RID: 21427 RVA: 0x0017A8B2 File Offset: 0x00178AB2
			protected override void OnTimedOut()
			{
				this.FailQuest();
			}

			// Token: 0x060053B4 RID: 21428 RVA: 0x0017A8BA File Offset: 0x00178ABA
			private void SucceedQuestWithBribe()
			{
				PlayerEncounter.LeaveEncounter = true;
				GiveGoldAction.ApplyForQuestBetweenCharacters(Hero.MainHero, null, this.BribeAmount, false);
				this.SucceedQuest(this.QuestSuccessWithBribeLog);
			}

			// Token: 0x060053B5 RID: 21429 RVA: 0x0017A8E0 File Offset: 0x00178AE0
			private void SucceedQuest(TextObject log)
			{
				base.AddLog(log, false);
				base.RemoveTrackedObject(this._targetSettlement);
				base.RemoveTrackedObject(this._originSettlement);
				this.RelationshipChangeWithQuestGiver = 10;
				this._targetSettlement.Town.Security += 10f;
				GiveGoldAction.ApplyForQuestBetweenCharacters(base.QuestGiver, Hero.MainHero, this.RewardGold, false);
				if (this._smugglerParty != null)
				{
					DestroyPartyAction.Apply(null, this._smugglerParty);
				}
				base.CompleteQuestWithSuccess();
			}

			// Token: 0x060053B6 RID: 21430 RVA: 0x0017A964 File Offset: 0x00178B64
			private void FailQuest()
			{
				TraitLevelingHelper.OnIssueFailed(Hero.MainHero, new Tuple<TraitObject, int>[]
				{
					new Tuple<TraitObject, int>(DefaultTraits.Honor, -50),
					new Tuple<TraitObject, int>(DefaultTraits.Valor, -50)
				});
				this.RelationshipChangeWithQuestGiver = -10;
				base.RemoveTrackedObject(this._targetSettlement);
				base.RemoveTrackedObject(this._originSettlement);
				base.CompleteQuestWithFail(this.QuestFailedLog);
				DestroyPartyAction.Apply(null, this._smugglerParty);
			}

			// Token: 0x060053B7 RID: 21431 RVA: 0x0017A9D8 File Offset: 0x00178BD8
			protected override void RegisterEvents()
			{
				CampaignEvents.OnSettlementOwnerChangedEvent.AddNonSerializedListener(this, new Action<Settlement, bool, Hero, Hero, Hero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail>(this.OnSettlementOwnerChanged));
				CampaignEvents.WarDeclared.AddNonSerializedListener(this, new Action<IFaction, IFaction, DeclareWarAction.DeclareWarDetail>(this.OnWarDeclared));
				CampaignEvents.OnClanChangedKingdomEvent.AddNonSerializedListener(this, new Action<Clan, Kingdom, Kingdom, ChangeKingdomAction.ChangeKingdomActionDetail, bool>(this.OnClanChangedKingdom));
				CampaignEvents.HourlyTickPartyEvent.AddNonSerializedListener(this, new Action<MobileParty>(this.OnHourlyTickParty));
				CampaignEvents.MapEventEnded.AddNonSerializedListener(this, new Action<MapEvent>(this.OnMapEventEnded));
			}

			// Token: 0x060053B8 RID: 21432 RVA: 0x0017AA58 File Offset: 0x00178C58
			private void OnMapEventEnded(MapEvent mapEvent)
			{
				if (mapEvent.IsPlayerMapEvent && mapEvent.InvolvedParties.Contains(this._smugglerParty.Party))
				{
					if (mapEvent.WinningSide == mapEvent.PlayerSide)
					{
						this.SucceedQuest(this.QuestSuccessWithFightLog);
						return;
					}
					this.FailQuest();
				}
			}

			// Token: 0x060053B9 RID: 21433 RVA: 0x0017AAA8 File Offset: 0x00178CA8
			private void OnHourlyTickParty(MobileParty mobileParty)
			{
				if (mobileParty == this._smugglerParty && mobileParty.CurrentSettlement != null)
				{
					if (this._smugglerSettlementWaitCounter >= 4)
					{
						this._smugglerSettlementWaitCounter = 0;
						Settlement settlement = (mobileParty.CurrentSettlement == this._targetSettlement) ? this._originSettlement : this._targetSettlement;
						SetPartyAiAction.GetActionForVisitingSettlement(mobileParty, settlement);
						return;
					}
					this._smugglerSettlementWaitCounter++;
				}
			}

			// Token: 0x060053BA RID: 21434 RVA: 0x0017AB09 File Offset: 0x00178D09
			private void OnClanChangedKingdom(Clan clan, Kingdom oldKingdom, Kingdom newKingdom, ChangeKingdomAction.ChangeKingdomActionDetail detail, bool showNotification = true)
			{
				if (clan == base.QuestGiver.Clan && newKingdom.IsAtWarWith(Clan.PlayerClan))
				{
					base.CompleteQuestWithCancel(this.QuestCanceledWarDeclaredLog);
				}
			}

			// Token: 0x060053BB RID: 21435 RVA: 0x0017AB32 File Offset: 0x00178D32
			private void OnWarDeclared(IFaction faction1, IFaction faction2, DeclareWarAction.DeclareWarDetail declareWarDetail)
			{
				QuestHelper.CheckWarDeclarationAndFailOrCancelTheQuest(this, faction1, faction2, declareWarDetail, this.QuestCanceledWarDeclaredLog, this.QuestCanceledWarDeclaredLog, false);
			}

			// Token: 0x060053BC RID: 21436 RVA: 0x0017AB4A File Offset: 0x00178D4A
			private void OnSettlementOwnerChanged(Settlement settlement, bool openToClaim, Hero newOwner, Hero oldOwner, Hero capturerHero, ChangeOwnerOfSettlementAction.ChangeOwnerOfSettlementDetail detail)
			{
				if (settlement == this._targetSettlement)
				{
					base.CompleteQuestWithCancel(this.QuestCanceledSettlementOwnerChangedLog);
				}
			}

			// Token: 0x060053BD RID: 21437 RVA: 0x0017AB61 File Offset: 0x00178D61
			protected override void InitializeQuestOnGameLoad()
			{
				this.SetDialogs();
			}

			// Token: 0x060053BE RID: 21438 RVA: 0x0017AB69 File Offset: 0x00178D69
			protected override void HourlyTick()
			{
			}

			// Token: 0x04001B2B RID: 6955
			[SaveableField(1)]
			private readonly Settlement _targetSettlement;

			// Token: 0x04001B2C RID: 6956
			[SaveableField(2)]
			private readonly Settlement _originSettlement;

			// Token: 0x04001B2D RID: 6957
			[SaveableField(3)]
			private MobileParty _smugglerParty;

			// Token: 0x04001B2E RID: 6958
			[SaveableField(4)]
			private readonly float _issueDifficulty;

			// Token: 0x04001B2F RID: 6959
			[SaveableField(5)]
			private int _smugglerSettlementWaitCounter;

			// Token: 0x04001B30 RID: 6960
			private const int FailRelationPenalty = -10;

			// Token: 0x04001B31 RID: 6961
			private const int SuccessRelationBonus = 10;

			// Token: 0x04001B32 RID: 6962
			private const int SuccessSecurityBonus = 10;

			// Token: 0x04001B33 RID: 6963
			private const int MaxSmugglerPartySize = 35;

			// Token: 0x04001B34 RID: 6964
			private const int MinSmugglerPartySize = 15;

			// Token: 0x04001B35 RID: 6965
			private const int SmugglerPartyWaitingHours = 4;

			// Token: 0x04001B36 RID: 6966
			private const string SmugglerPersuasionDialogToken = "start_smugglers_persuasion";

			// Token: 0x04001B37 RID: 6967
			private readonly string[] _possibleSmuggledItems = new string[]
			{
				"jewelry",
				"spice",
				"velvet",
				"fur"
			};

			// Token: 0x04001B38 RID: 6968
			private PersuasionTask _task;

			// Token: 0x04001B39 RID: 6969
			private const PersuasionDifficulty Difficulty = PersuasionDifficulty.MediumHard;
		}

		// Token: 0x02000675 RID: 1653
		public class SmugglersIssueTypeDefiner : SaveableTypeDefiner
		{
			// Token: 0x060053C6 RID: 21446 RVA: 0x0017ABFE File Offset: 0x00178DFE
			public SmugglersIssueTypeDefiner() : base(585960)
			{
			}

			// Token: 0x060053C7 RID: 21447 RVA: 0x0017AC0B File Offset: 0x00178E0B
			protected override void DefineClassTypes()
			{
				base.AddClassDefinition(typeof(SmugglersIssueBehavior.SmugglersIssue), 1, null);
				base.AddClassDefinition(typeof(SmugglersIssueBehavior.SmugglersIssueQuest), 2, null);
			}
		}
	}
}
